﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

using Weazel.Math;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace Weazel.Math.Test
{
  [TestClass]
  public class TestSignedDivision
  {
    /**************************************************************************
		 * Division 
		 **************************************************************************/
    [TestMethod]
    public void TestSignedDivision_1()
    {
      Integer a = new Integer(8, 10, true);
      Integer b = new Integer(8, 2, true);
      Assert.AreEqual("5", (a / b).ToDecimalString());
    }

    [TestMethod]
    public void TestSignedDivision_2()
    {
      Integer a = new Integer(8, 10, true);
      Integer b = new Integer(8, -2, true);
      Assert.AreEqual("-5", (a / b).ToDecimalString());
    }

    [TestMethod]
    public void TestSignedDivision_3()
    {
      Integer a = new Integer(8, -10, true);
      Integer b = new Integer(8, 2, true);
      Assert.AreEqual("-5", (a / b).ToDecimalString());
    }

    [TestMethod]
    public void TestSignedDivision_4()
    {
      Integer a = new Integer(8, -10, true);
      Integer b = new Integer(8, -2, true);
      Assert.AreEqual("5", (a / b).ToDecimalString());
    }

    [TestMethod]
    public void TestSignedDivision_5()
    {
      Integer a = new Integer(64, "123456789101112", true);
      Integer b = new Integer(64, 0, true);

      try
      {
        Integer r = a / b;
        Assert.Fail("Expected DivideByZeroException");
      }
      catch (Exception e)
      {
        Assert.IsTrue(e is DivideByZeroException);
      }
    }

    /* long division */

    [TestMethod]
    public void TestSignedDivision_6()
    {
      Integer a = new Integer(64, "123456789101112", true);
      Integer b = new Integer(64, "123456789101112", true);
      Assert.AreEqual("1", (a / b).ToDecimalString());
    }
  }
}
